<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dettaglio news</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../../css/main.css" rel="stylesheet" />
<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/scriptaculous.js"></script>
<script type="text/javascript" src="../../js/controls.js"></script>
<script type="text/javascript" src="../../js/page.js"></script>
<script type="text/javaScript">
function go(par, news){
    if(par == 2){
        if(!confirm("Sei sicuro di voler cancellare questa news?"))
            return false;
    }
    $('_i').value = news;
    $('action').value = par;
    var url = "<?php print $_SESSION['__config__']['root_site'] ?>admin/adm_news/news_manager.php";
	var req = new Ajax.Request(url,
			  {
			    	method:'post',
			    	parameters: $('news_form').serialize(true),
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		//alert(response);
			      		var dati = response.split("|");
			      		if(dati[0] == "ko"){
							alert("Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2]);
							return;
			      		}
			      		parent.win.close();
			      		link = "news.php?msg="+par;
			      		if(par != 1){
							link += "&second=1&offset=<?php print $offset ?>";
			      		}

						parent.document.location.href = link;
			      		//parent.win.close();
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore..."); }
			  });
}

function sleep(milliseconds) {
	var start = new Date().getTime();
  	for (var i = 0; i < 1e7; i++) {
    	if ((new Date().getTime() - start) > milliseconds){
      		break;
    	}
  	}
}



</script>
</head>
<body style="background-color: #FFFFFF">
    <p class="popup_header">Gestione news</p>
    <form action="news_manager.php" method="post" id="news_form">
    <table style="width: 500px; margin: auto">
        <tr class="popup_row header_row">
            <td class="popup_title" style="width: 150px">Titolo</td>
            <td style="width: 350px">
                <input class="form_input" type="text" name="titolo" style="width: 350px" value="<?php if(isset($news)) print utf8_decode($news['abstract']) ?>" />
            </td>
        </tr>
        <tr class="popup_row">
            <td class="popup_title" style="width: 150px">Testo</td>
            <td style="width: 350px">     
                <textarea class="form_input" style="width: 350px; height: 150px" name="testo"><?php if(isset($news)) print utf8_decode($news['testo']) ?></textarea>
            </td>
        </tr>
        <tr class="popup_row">
            <td colspan="2">
            	<input type="hidden" name="action" id="action" />
    			<input type="hidden" name="_i" id="_i" />
            </td>
        </tr>
        <tr>
            <td colspan="2" style="margin-right: 30px; text-align: right">
                <a href="#" onclick="go(<?php if(isset($_GET['id']) && $_REQUEST['id'] != 0) print("3, ".$_REQUEST['id']); else print("1, 0"); ?>)" class="nav_link_first">Registra</a>|
                <?php if(isset($_REQUEST['id']) && $_REQUEST['id'] != 0){
                ?>
                <a href="#" onclick="go(2, <?php print $_REQUEST['id'] ?>)" class="nav_link">Cancella news</a>|
                <?php
                }
                ?>
                <a  href="#" onclick="parent.win.close()" class="nav_link_last">Chiudi</a>
            </td>
        </tr>
    </table>
   </form>
</body>
</html>